﻿using Architecture.API.Application.Command.RequestForLeaveCommand;
using Architecture.Domain.Dto.LeaveDto;
using Architecture.Domain.Service.LeaveServices;
using Architecture.Domain.Service.UserInfoServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.RequestForLeaveHandler
{
    /// <summary>
    /// 用户信息查询服务
    /// </summary>
    public class UserInfoDepartmentCommandHandler : IRequestHandler<UserInfoDepartmentCommand, List<UserInfoDepartmentDto>>
    {
        /// <summary>
        /// 请假信息服务
        /// </summary>
        protected readonly ILeaveService leaveService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="leaveService">请假信息服务</param>
        public UserInfoDepartmentCommandHandler(ILeaveService leaveService)
        {
            this.leaveService = leaveService;
        }

        /// <summary>
        /// 通过部门ID获取用户信息列表
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回用户信息</returns>
        public async Task<List<UserInfoDepartmentDto>> Handle(UserInfoDepartmentCommand request, CancellationToken cancellationToken)
        {
            return await leaveService.GetUserInfoDepartment(request.departmentId);
        }
    }
}
